package com.xinhe.web.controller;

import com.querydsl.core.QueryResults;
import com.xinhe.web.annotation.WebUsed;
import com.xinhe.web.common.Result;
import com.xinhe.web.entity.Studio;
import com.xinhe.web.response.StudioView;
import com.xinhe.web.service.StudioService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(value = "工作室", tags = {"工作室"})
@RestController
@RequestMapping(value = {"/studio"}, produces = {"application/json;charset=UTF-8"})

public class StudioController {
    @Autowired
    private StudioService studioService;

    @WebUsed
    @ApiOperation(httpMethod = "GET", value = "分页查询工作室")
    @RequestMapping({"/pageStudio"})
    public QueryResults<StudioView> pageStudio(Long userId, String name, String codeName, String address, String longitude,
                                               String latitude, Integer seq, String remark,int pageNum, int pageSize) {
        return this.studioService.pageStudio( userId,  name,  codeName,  address,  longitude,
                 latitude,  seq,  remark,pageNum,pageSize);
    }

    @WebUsed
    @ApiOperation(httpMethod = "POST", value = "保存工作室")
    @RequestMapping({"/saveStudio"})
    public Result saveStudio(Long id,Long userId, String name, String codeName, String address, String longitude,
                             String latitude, Integer seq, String remark) {
        return this.studioService.saveStudio(id,userId,  name,  codeName,  address,  longitude,
                latitude,  seq,  remark);
    }

    @WebUsed
    @ApiOperation(httpMethod = "GET", value = "删除工作室")
    @ApiImplicitParam(name = "studioId", value = "标识", dataTypeClass = Long.class, required = true)
    @RequestMapping({"/deleteStudio"})
    public Result deleteStudio(Long studioId) {
        return this.studioService.delete(studioId);
    }

    @WebUsed
    @ApiOperation(httpMethod = "GET", value = "工作室详情")
    @ApiImplicitParam(name = "studioId", value = "标识", dataTypeClass = Long.class, required = true)
    @RequestMapping({"/detailStudio"})
    public Result<Studio> detailStudio(Long studioId) {
        return this.studioService.findById(studioId);
    }
}
